import java.util.Arrays;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/12 16:07
 * @copyright: 博为峰
 */
public class ArrayTest04 {
    public static void main(String[] args) {
        int[] arr = {20, 9, 15, 3, 26, 6, 11};
        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ",");
        }
        System.out.println();

        /*
             二分查找（有序数组） 3,6,9,11,15,20,26,2
             参数1: 数组
             参数2: 要查询的数据
         */
        int r = Arrays.binarySearch(arr, 9);
        System.out.println(r);
    }
}
